package com.usian.skill.service.impl;

import com.usian.skill.mapper.SkillGoodsMapper;
import com.usian.skill.mapper.SkillOrderMapper;
import com.usian.skill.pojo.OrderInfo;
import com.usian.skill.pojo.SkillOrder;
import com.usian.skill.service.OrderInfoService;
import com.usian.skill.service.SkillService;
import com.usian.skill.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class SkillServiceimpl implements SkillService {

    @Resource
    private SkillGoodsMapper skillGoodsMapper;
    @Autowired
    private OrderInfoService orderInfoService;

    @Override
    public OrderInfo deleteKuCunAndAddDingDan(String userId, GoodsVo goodsVo) {
//       删除库存
        int i = skillGoodsMapper.deleteKuCun(goodsVo.getId());
        if (i>0){
//            库存删除成功 创建订单
            return orderInfoService.addDingDan(userId,goodsVo);
        }
        return null;
    }
}
